<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "elective".
 *
 * @property int $ID ID
 * @property int $XSID 学生ID
 * @property int $JXKCID 教学课程ID
 * @property string $XXSJ 选修时间
 * @property float|null $PSCJ 平时成绩
 * @property float|null $SYCJ 实验成绩
 * @property float|null $SJCJ 实践成绩
 * @property float|null $KSCJ 考试成绩
 * @property float|null $ZCJ 总成绩
 * @property float|null $HDXF 获得学分
 * @property string $SHZT 审核状态
 *
 * @property Student $xS
 * @property CourseTeacher $jXKC
 */
class Elective extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'elective';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['XSID', 'JXKCID', 'XXSJ', 'SHZT'], 'required'],
            [['XSID', 'JXKCID'], 'integer'],
            [['XXSJ'], 'safe'],
            [['PSCJ', 'SYCJ', 'SJCJ', 'KSCJ', 'ZCJ', 'HDXF'], 'number'],
            [['SHZT'], 'string', 'max' => 10],
            [['XSID'], 'exist', 'skipOnError' => true, 'targetClass' => Student::className(), 'targetAttribute' => ['XSID' => 'ID']],
            [['JXKCID'], 'exist', 'skipOnError' => true, 'targetClass' => CourseTeacher::className(), 'targetAttribute' => ['JXKCID' => 'ID']],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'ID' => 'ID',
            'XSID' => '学生ID',
            'JXKCID' => '教学课程ID',
            'XXSJ' => '选修时间',
            'PSCJ' => '平时成绩',
            'SYCJ' => '实验成绩',
            'SJCJ' => '实践成绩',
            'KSCJ' => '考试成绩',
            'ZCJ' => '总成绩',
            'HDXF' => '获得学分',
            'SHZT' => '审核状态',
        ];
    }

    /**
     * Gets query for [[XS]].
     *
     * @return \yii\db\ActiveQuery
     */
    public function getXS()
    {
        return $this->hasOne(Student::className(), ['ID' => 'XSID'])->inverseOf('electives');
    }

    /**
     * Gets query for [[JXKC]].
     *
     * @return \yii\db\ActiveQuery
     */
    public function getJXKC()
    {
        return $this->hasOne(CourseTeacher::className(), ['ID' => 'JXKCID'])->inverseOf('electives');
    }
}
